﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using skhukb.DB;

namespace skhukb.BL
{   
    public class MyRoleProvider : RoleProvider {

        public const string ADMIN = "admin";
        public const string USER = "user";

        static string[] 관리자 = { ADMIN, USER };
        static string[] 일반사용자 = { USER };

        public override string[] GetRolesForUser(string username)
        {
            if (username == 현재사용자.사용자.ID.ToString())
                return 현재사용자.사용자.관리자 ? 관리자 : 일반사용자;

            using (var db = new DBDataContext()) {
                int 사용자ID = 0;
                int.TryParse(username, out 사용자ID);
                var user = db.사용자.FirstOrDefault(p => p.ID == 사용자ID);
                if (user == null) return null;
                return user.관리자 ? 관리자 : 일반사용자;
            }
        }

        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override string ApplicationName
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override void CreateRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            throw new NotImplementedException();
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            throw new NotImplementedException();
        }

        public override string[] GetAllRoles()
        {
            throw new NotImplementedException();
        }

        public override string[] GetUsersInRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool IsUserInRole(string username, string roleName)
        {
            throw new NotImplementedException();
        }

        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override bool RoleExists(string roleName)
        {
            throw new NotImplementedException();
        }
    }

}